<?php
	include_once 'isLogin.php';
	$adminc = new admin();
	$id = $_GET['id'] =1;
	$avatar_dir = $_c['dir'] . '/avatar/';

	if($id){
		$info = $adminc->getAdminInfo($id);
	}
	$smarty->assign("info" , $info);
	
	$avatar = $info['avatar'];
	
	if($_POST){
		if($_FILES['avatar']['name'] != ''){
			//删除旧图
			@unlink($avatar_dir.$avatar);
			
			//上传新图
			//$avatar = $commonc->uploadFile('avatar',$avatar_dir);
			$upimg = new uploadImg();
			$avatar = $upimg -> upLoad('avatar',$avatar_dir);
			//压缩后
			//$upimg->smallImg($folder.$thumbnail,$makeFolder,'','380','380',true);
		}

		$arr = array(
				'avatar' => $avatar,
				'last_edit_date' => time(),
			);
		$res = $adminc->adminUpdate($arr,'id="'.$id.'"');
		$url = $page_basename.'?id='.$id;
		$msg = '上传成功';
		echo $commonc->submitAlert($msg,$url);
		exit();
	}
	
	$smarty->display("example_up.html");
?>